package org.linys.dao.system;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.linys.model.system.Operator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class OperatorDAO {
	
	private SqlSession sqlSession;
	@Autowired
	public void setSqlSession(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}

	public Operator get(Integer id) {
		return (Operator) sqlSession.selectOne("OperatorMapper.select", id);
	}

	public int save(Operator operator){
		 return sqlSession.insert("OperatorMapper.insert", operator);
	}

	@SuppressWarnings("unchecked")
	public List<Operator> list(Operator operator, Integer offset, Integer limit) {
		return sqlSession.selectList("OperatorMapper.list",operator,new RowBounds(offset,limit));
	}


	
	public int deleteByID(Integer id) {
		return sqlSession.delete("OperatorMapper.delete", id);
	}

	public int update(Operator operator) {
		return sqlSession.update("OperatorMapper.update", operator);
	}

	public Operator login(Operator operator) {
		return (Operator) sqlSession.selectOne("OperatorMapper.login", operator);
	}

	public int count(Operator operator) {
		return (Integer) sqlSession.selectOne("OperatorMapper.count", operator);
	}

	public int changeWindowStyle(Operator operator) {
		return sqlSession.update("OperatorMapper.changeWindowStyle", operator);
	}

	public int updatePassword(Operator operator) {
		return sqlSession.update("OperatorMapper.updatePassword", operator);
	}

	public int validatePassword(Operator operator) {
		return (Integer) sqlSession.selectOne("OperatorMapper.validatePassword", operator);
	}

}
